package com.api.shopapi.service.impl;

import com.api.shopapi.entity.JKNiaosuan;
import com.api.shopapi.entity.dto.JKNiaosuanDTO;
import com.api.shopapi.mapper.JKNiaosuanMapper;
import com.api.shopapi.service.JKNiaosuanService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("JKNiaosuanServiceImplOne")
public class JKNiaosuanServiceImpl implements JKNiaosuanService {

    @Autowired
    private JKNiaosuanMapper jkNiaosuanMapper;

    @Override
    public int insert(JKNiaosuan jkNiaosuan) {
        return jkNiaosuanMapper.insert(jkNiaosuan);
    }

    @Override
    public int update(JKNiaosuan jkNiaosuan) {
        return jkNiaosuanMapper.update(jkNiaosuan);
    }

    @Override
    public int delete(String jkNiaosuanCode) {
        return jkNiaosuanMapper.delete(jkNiaosuanCode);
    }

    @Override
    public JKNiaosuan getByJkNiaosuanCode(String jkNiaosuanCode) {
        return jkNiaosuanMapper.getByJKNiaosuanCode(jkNiaosuanCode);
    }

    @Override
    public PageInfo<JKNiaosuan> getPageList(int pageIndex, int pageSize, String userCode,String startTime,String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<JKNiaosuan> jkNiaosuanList = jkNiaosuanMapper.getPageList(userCode,startTime,endTime);
        return new PageInfo<>(jkNiaosuanList);
    }

    @Override
    public PageInfo<JKNiaosuanDTO> getAdmPageList(int pageIndex, int pageSize, String name, String governmentCode, String startTime, String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<JKNiaosuanDTO> jkNiaosuanDTOList = jkNiaosuanMapper.getAdmPageList(name, governmentCode, startTime, endTime);
        return new PageInfo<>(jkNiaosuanDTOList);
    }
}
